package com.eascs.finance.admin.web.controller;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.eascs.finance.admin.common.entity.Attachment;
import com.eascs.finance.admin.web.service.AttachmentService;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.BaseRestResult;


@RestController
public class AttachmentRestController extends BaseRestController {
	@Inject
	private AttachmentService attachmentService;

	@RequestMapping("/attachment/upload"  )
	public BaseRestResult<Attachment> uploadAttachment(@RequestParam(value = "file", required = true) MultipartFile file) {
		Attachment attachment = this.attachmentService.uploadAttachment(file);
		return BaseRestResult.buildRestResult(attachment);
	}

}
